﻿using BCCommon;
using BCDto.CRM.BigCustomerTradeRecord;
using BCService.CRM.BigCustomerTradeRecord;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.Management.CRM.BigCustomerTradeRecord
{
    [ApiExplorerSettings(GroupName = "CRMAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class BigCustomerTradeRecordController : ManagementBaseController
    {
        #region var
        private IBigCustomerTradeRecordService bigCustomerTradeRecordService;
        #endregion


        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary> 
        public BigCustomerTradeRecordController(IBigCustomerTradeRecordService bigCustomerTradeRecordService)
        {
            this.bigCustomerTradeRecordService = bigCustomerTradeRecordService;
        }
        #endregion

        #region POST 添加 添加新大客户交易记录纪录 大客户交易记录数据模型

        [Log("添加新大客户交易记录纪录")]
        [HttpPost]
        [ProducesResponseType(typeof(BigCustomerTradeRecordRequestDto), 200)]
        public IActionResult Post([FromBody] BigCustomerTradeRecordRequestDto dto)
        {
            var a = bigCustomerTradeRecordService.Add(dto, this.Admin);
            return Ok(a);
        }

        #endregion

        #region PUT 修改 修改大客户交易记录纪录  大客户交易记录数据模型

        [Log("修改大客户交易记录纪录")]
        [HttpPut]
        [ProducesResponseType(typeof(BigCustomerTradeRecordDto), 200)]
        public IActionResult Put([FromBody] BigCustomerTradeRecordDto dto)
        {
            var a = Ok(bigCustomerTradeRecordService.Update(dto, this.Admin));
            return a;
        }
        #endregion

        #region 删除 删除大客户交易记录纪录 大客户交易记录ID

        [Log("删除大客户交易记录纪录")]
        [HttpDelete("{big_customer_trade_record_id}")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "big_customer_trade_record_id")] long bigCustomerTradeRecordId)
        {
            bigCustomerTradeRecordService.Delete(bigCustomerTradeRecordId);
            return NoContent();
        }
        #endregion

        #region GetByID   获取一条大客户交易记录纪录  大客户交易记录ID

        [HttpGet("{big_customer_trade_record_id}")]
        [ProducesResponseType(typeof(BigCustomerTradeRecordDto), 200)]
        public IActionResult Get([FromRoute(Name = "big_customer_trade_record_id")] long bigCustomerTradeRecordId)
        {
            return (Ok(bigCustomerTradeRecordService.GetById(bigCustomerTradeRecordId)));

        }
        #endregion

        #region Query 查询大客户交易记录

        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<BigCustomerTradeRecordDto>), 200)]
        public IActionResult Query([FromQuery(Name = "index")] int? pageIndex = 1, [FromQuery(Name = "size")] int? pageSize = 10)
        {
            var a = Ok(bigCustomerTradeRecordService.GetList(pageIndex.Value, pageSize.Value));
            return a;
        }
        #endregion
    }

}
